package com.xhd.db;

import java.lang.reflect.Field;
import java.text.SimpleDateFormat;
import java.util.Collection;
import java.util.List;
import java.util.Vector;

import com.xhd.base.log.Log;
import com.xhd.base.log.LogFactory;
import com.xhd.base.obj.EnpObjClass;
import com.xhd.base.util.xBaseObj;
import com.xhd.util.DataFilter;
import com.xhd.util.DataFormat;
import com.xhd.util.XDate;

public class DBWhereExp {
	  Vector jm6 = new Vector();
	  Vector jm7 = null;
	  boolean jm8 = true;
	  private static final Log logobj;
	  static Class objclas;

	  static
	  {
	    Class tempobjclas = objclas;
	    if (tempobjclas == null)
	    {
	     
	      try
	      {
	         DBWhereExp.objclas = Class.forName("com.sinocc.systemdbmanager.DBWhereExp");
	      }
	      catch (ClassNotFoundException localClassNotFoundException)
	      {
	        throw new NoClassDefFoundError(localClassNotFoundException.getMessage());
	      }
	    }
	    logobj = LogFactory.getLog(tempobjclas);
	  }

	  private DBWhereExp()
	  {
	  }

	  public boolean isNull()
	  {
	    return ((this.jm6.size() < 1) && (this.jm7 == null));
	  }

	  public DBWhereExp(String paramString)
	  {
	    if (paramString == null)
	      return;
	    paramString = paramString.trim();
	    if (paramString.length() < 1)
	      return;
	    if ((paramString.length() > 6) && (paramString.toLowerCase().startsWith("where ")))
	      paramString = paramString.substring(6);
	    ExpItem localExpItem = new ExpItem(paramString, null, null);
	    this.jm6.add(localExpItem);
	  }

	  private String jm0(Class paramClass)
	  {
	    String str = paramClass.getName();
	    int i = str.lastIndexOf(46);
	    if (i >= 0)
	      str = str.substring(i + 1);
	    return str.toLowerCase();
	  }

	  public void setAnd(boolean paramBoolean)
	  {
	    this.jm8 = paramBoolean;
	  }

	  public boolean isAnd()
	  {
	    return this.jm8;
	  }

	  public String toSQL(int paramInt)
	  {
	    StringBuffer localStringBuffer = new StringBuffer(128);
	    int i = this.jm6.size();
	    if (this.jm7 != null)
	      i += this.jm7.size();
	    if (i > 1)
	      localStringBuffer.append('(');
	    Object localObject;
	    for (int j = 0; j < this.jm6.size(); ++j)
	    {
	      localObject = (ExpItem)this.jm6.get(j);
	      if ((localStringBuffer.length() > 1) || (j > 0))
	        localStringBuffer.append((((ExpItem)localObject).jm8) ? " AND " : " OR ");
	      localStringBuffer.append(((ExpItem)localObject).toSQL(paramInt));
	    }
	    if (this.jm7 != null)
	    {
	      for ( int j = 0; j < this.jm7.size(); ++j)
	      {
	        localObject = (DBWhereExp)this.jm7.get(j);
	        if (j == 0)
	          if (localStringBuffer.length() > 0)
	            localStringBuffer.append((((DBWhereExp)localObject).isAnd()) ? " AND (" : " OR (");
	          else
	            localStringBuffer.append("(");
	        else
	          localStringBuffer.append((((DBWhereExp)localObject).isAnd()) ? " AND " : " OR ");
	        localStringBuffer.append(((DBWhereExp)localObject).toSQL(paramInt));
	      }
	      localStringBuffer.append(")");
	    }
	    if (i > 1)
	      localStringBuffer.append(')');
	    return ((String)localStringBuffer.toString());
	  }

	  public String toDBSQL(int paramInt, DBSQL paramDBSQL, boolean paramBoolean)
	  {
	    StringBuffer localStringBuffer = new StringBuffer(128);
	    int i = this.jm6.size();
	    if (this.jm7 != null)
	      i += this.jm7.size();
	    if (i > 1)
	      localStringBuffer.append('(');
	    Object localObject;
	    for (int j = 0; j < this.jm6.size(); ++j)
	    {
	      localObject = (ExpItem)this.jm6.get(j);
	      if ((localStringBuffer.length() > 1) || (j > 0))
	        localStringBuffer.append((((ExpItem)localObject).jm8) ? " AND " : " OR ");
	      localStringBuffer.append(((ExpItem)localObject).toDBSQL(paramInt, paramDBSQL));
	    }
	    if (this.jm7 != null)
	    {
	      for ( int j = 0; j < this.jm7.size(); ++j)
	      {
	        localObject = (DBWhereExp)this.jm7.get(j);
	        if (j == 0)
	          if (localStringBuffer.length() > 0)
	            localStringBuffer.append((((DBWhereExp)localObject).isAnd()) ? " AND (" : " OR (");
	          else
	            localStringBuffer.append("(");
	        else
	          localStringBuffer.append((((DBWhereExp)localObject).isAnd()) ? " AND " : " OR ");
	        localStringBuffer.append(((DBWhereExp)localObject).toDBSQL(paramInt, paramDBSQL, false));
	      }
	      localStringBuffer.append(")");
	    }
	    if (i > 1)
	      localStringBuffer.append(')');
	    if (paramBoolean)
	      paramDBSQL.appendSQL(localStringBuffer.toString());
	    return ((String)localStringBuffer.toString());
	  }

	  private void jm1(String paramString1, Object paramObject, String paramString2)
	  {
	    ExpItem localExpItem = new ExpItem(paramString1, paramObject, paramString2);
	    localExpItem.setAnd(true);
	    this.jm6.add(localExpItem);
	  }

	  private void jm1(String paramString, Object[] paramArrayOfObject)
	  {
	    ExpItem localExpItem = new ExpItem(paramString, paramArrayOfObject);
	    localExpItem.setAnd(true);
	    this.jm6.add(localExpItem);
	  }

	  private void jm2(String paramString1, Object paramObject, String paramString2)
	  {
	    ExpItem localExpItem = new ExpItem(paramString1, paramObject, paramString2);
	    localExpItem.setAnd(false);
	    this.jm6.add(localExpItem);
	  }

	  private Vector jm3()
	  {
	    return this.jm6;
	  }

	  public DBWhereExp and(DBWhereExp paramDBWhereExp)
	  {
	    if ((paramDBWhereExp == null) || (paramDBWhereExp.isNull()))
	      return this;
	    Vector localVector = paramDBWhereExp.jm3();
	    if (localVector != null)
	    {
	      ExpItem localExpItem = (ExpItem)localVector.get(0);
	      localExpItem.setAnd(true);
	      this.jm6.addAll(localVector);
	    }
	    return this;
	  }

	  public DBWhereExp or(DBWhereExp paramDBWhereExp)
	  {
	    if ((paramDBWhereExp == null) || (paramDBWhereExp.isNull()))
	      return this;
	    Vector localVector = paramDBWhereExp.jm3();
	    if (localVector != null)
	    {
	      ExpItem localExpItem = (ExpItem)localVector.get(0);
	      localExpItem.setAnd(false);
	      this.jm6.addAll(localVector);
	    }
	    return this;
	  }

	  public void andSubExp(DBWhereExp paramDBWhereExp)
	  {
	    if ((paramDBWhereExp == null) || (paramDBWhereExp.isNull()))
	      return;
	    if (this.jm7 == null)
	      this.jm7 = new Vector();
	    paramDBWhereExp.setAnd(true);
	    this.jm7.add(paramDBWhereExp);
	  }

	  public void orSubExp(DBWhereExp paramDBWhereExp)
	  {
	    if ((paramDBWhereExp == null) || (paramDBWhereExp.isNull()))
	      return;
	    if (this.jm7 == null)
	      this.jm7 = new Vector();
	    paramDBWhereExp.setAnd(false);
	    this.jm7.add(paramDBWhereExp);
	  }

	  public static DBWhereExp eq(xBaseObj paramxBaseObj, String paramString, boolean paramBoolean)
	  {
	    if ((paramxBaseObj == null) || (paramString == null))
	      return null;
	    DBWhereExp localDBWhereExp = new DBWhereExp();
	    EnpObjClass localEnpObjClass = EnpObjClass.getInstance(paramxBaseObj.getClass());
	    String[] arrayOfString = DataFormat.splitString(paramString, ",");
	    try
	    {
	      for (int j = 0; j < arrayOfString.length; ++j)
	      {
	        String str = arrayOfString[j];
	        int i = str.indexOf(46);
	        if (i > 0)
	          str = str.substring(i + 1);
	        Field localField = localEnpObjClass.getField(str);
	        if (paramBoolean)
	          localDBWhereExp.jm1(arrayOfString[j], localField.get(paramxBaseObj), "=");
	        else
	          localDBWhereExp.jm2(arrayOfString[j], localField.get(paramxBaseObj), "=");
	      }
	    }
	    catch (Exception localException)
	    {
	      logobj.error(localException);
	      return null;
	    }
	    return localDBWhereExp;
	  }

	  public static DBWhereExp eq(xBaseObj paramxBaseObj, List paramList, boolean paramBoolean)
	  {
	    if ((paramxBaseObj == null) || (paramList == null))
	      return null;
	    DBWhereExp localDBWhereExp = new DBWhereExp();
	    EnpObjClass localEnpObjClass = EnpObjClass.getInstance(paramxBaseObj.getClass());
	    try
	    {
	      int j = paramList.size();
	      Field localField = null;
	      for (int k = 0; k < j; ++k)
	      {
	        String str = (String)paramList.get(k);
	        int i = str.indexOf(46);
	        if (i > 0)
	          localField = localEnpObjClass.getField(str.substring(i + 1));
	        else
	          localField = localEnpObjClass.getField(str);
	        if (localField == null)
	          continue;
	        if (paramBoolean)
	          localDBWhereExp.jm1(str, localField.get(paramxBaseObj), "=");
	        else
	          localDBWhereExp.jm2(str, localField.get(paramxBaseObj), "=");
	      }
	    }
	    catch (Exception localException)
	    {
	      logobj.error(localException);
	      return null;
	    }
	    return localDBWhereExp;
	  }

	  public static DBWhereExp eq(xBaseObj paramxBaseObj, String paramString)
	  {
	    if ((paramxBaseObj == null) || (paramString == null))
	      return null;
	    DBWhereExp localDBWhereExp = new DBWhereExp();
	    EnpObjClass localEnpObjClass = EnpObjClass.getInstance(paramxBaseObj.getClass());
	    try
	    {
	      Field localField = null;
	      int i = paramString.indexOf(46);
	      if (i > 0)
	        localField = localEnpObjClass.getField(paramString.substring(i + 1));
	      else
	        localField = localEnpObjClass.getField(paramString);
	      if (localField == null)
	        return null;
	      localDBWhereExp.jm1(paramString, localField.get(paramxBaseObj), "=");
	    }
	    catch (Exception localException)
	    {
	      logobj.error(localException);
	      return null;
	    }
	    return localDBWhereExp;
	  }

	  public static DBWhereExp like(xBaseObj paramxBaseObj, String paramString)
	  {
	    if ((paramxBaseObj == null) || (paramString == null))
	      return null;
	    DBWhereExp localDBWhereExp = new DBWhereExp();
	    EnpObjClass localEnpObjClass = EnpObjClass.getInstance(paramxBaseObj.getClass());
	    try
	    {
	      int i = paramString.indexOf(46);
	      if (i > 0)
	      {
	    	Field localField = localEnpObjClass.getField(paramString.substring(i + 1));
	        localDBWhereExp.jm1(paramString, localField.get(paramxBaseObj), "like");
	       /* break label108:*/
	      }
	      Field localField = localEnpObjClass.getField(paramString);
	      localDBWhereExp.jm1(paramString, localField.get(paramxBaseObj), "like");
	    }
	    catch (Exception localException)
	    {
	      logobj.error(localException);
	      return null;
	    }
	    label108: return localDBWhereExp;
	  }

	  public static DBWhereExp like(xBaseObj paramxBaseObj, String paramString, boolean paramBoolean)
	  {
	    if ((paramxBaseObj == null) || (paramString == null))
	      return null;
	    DBWhereExp localDBWhereExp = new DBWhereExp();
	    EnpObjClass localEnpObjClass = EnpObjClass.getInstance(paramxBaseObj.getClass());
	    String[] arrayOfString = DataFormat.splitString(paramString, ",");
	    try
	    {
	      for (int j = 0; j < arrayOfString.length; ++j)
	      {
	        String str1 = arrayOfString[j];
	        int i = str1.indexOf(46);
	        if (i > 0)
	          str1 = str1.substring(i + 1);
	        Field localField = localEnpObjClass.getField(str1);
	        String str2 = (String)localField.get(paramxBaseObj);
	        if ((str2 == null) || (str2.length() <= 0))
	          continue;
	        if (paramBoolean)
	          localDBWhereExp.jm1(arrayOfString[j], localField.get(paramxBaseObj), "like");
	        else
	          localDBWhereExp.jm2(arrayOfString[j], localField.get(paramxBaseObj), "like");
	      }
	    }
	    catch (Exception localException)
	    {
	      logobj.error(localException);
	      return null;
	    }
	    if (localDBWhereExp.isNull())
	      return null;
	    return localDBWhereExp;
	  }

	  public static DBWhereExp likeAll(xBaseObj paramxBaseObj, String paramString)
	  {
	    if ((paramxBaseObj == null) || (paramString == null))
	      return null;
	    DBWhereExp localDBWhereExp = new DBWhereExp();
	    EnpObjClass localEnpObjClass = EnpObjClass.getInstance(paramxBaseObj.getClass());
	    try
	    {
	      int i = paramString.indexOf(46);
	      if (i > 0)
	      {
	        Field localField = localEnpObjClass.getField(paramString.substring(i + 1));
	        localDBWhereExp.jm1(paramString, localField.get(paramxBaseObj), "likeall");
	       /* break label108:*/
	      }
	      Field localField = localEnpObjClass.getField(paramString);
	      localDBWhereExp.jm1(paramString, localField.get(paramxBaseObj), "likeall");
	    }
	    catch (Exception localException)
	    {
	      logobj.error(localException);
	      return null;
	    }
	    label108: return localDBWhereExp;
	  }

	  public static DBWhereExp notLike(xBaseObj paramxBaseObj, String paramString)
	  {
	    if ((paramxBaseObj == null) || (paramString == null))
	      return null;
	    DBWhereExp localDBWhereExp = new DBWhereExp();
	    EnpObjClass localEnpObjClass = EnpObjClass.getInstance(paramxBaseObj.getClass());
	    try
	    {
	      int i = paramString.indexOf(46);
	      if (i > 0)
	      {
	    	Field localField = localEnpObjClass.getField(paramString.substring(i + 1));
	        localDBWhereExp.jm1(paramString, localField.get(paramxBaseObj), "notlike");
	       /* break label108:*/
	      }
	      Field localField = localEnpObjClass.getField(paramString);
	      localDBWhereExp.jm1(paramString, localField.get(paramxBaseObj), "notlike");
	    }
	    catch (Exception localException)
	    {
	      logobj.error(localException);
	      return null;
	    }
	    label108: return localDBWhereExp;
	  }

	  public static DBWhereExp notLikeAll(xBaseObj paramxBaseObj, String paramString)
	  {
	    if ((paramxBaseObj == null) || (paramString == null))
	      return null;
	    DBWhereExp localDBWhereExp = new DBWhereExp();
	    EnpObjClass localEnpObjClass = EnpObjClass.getInstance(paramxBaseObj.getClass());
	    try
	    {
	      int i = paramString.indexOf(46);
	      if (i > 0)
	      {
	        Field localField = localEnpObjClass.getField(paramString.substring(i + 1));
	        localDBWhereExp.jm1(paramString, localField.get(paramxBaseObj), "notlikeall");
	        /*break label108:*/
	      }
	      Field localField = localEnpObjClass.getField(paramString);
	      localDBWhereExp.jm1(paramString, localField.get(paramxBaseObj), "notlikeall");
	    }
	    catch (Exception localException)
	    {
	      logobj.error(localException);
	      return null;
	    }
	    label108: return localDBWhereExp;
	  }

	  public static DBWhereExp ne(xBaseObj paramxBaseObj, String paramString)
	  {
	    if ((paramxBaseObj == null) || (paramString == null))
	      return null;
	    DBWhereExp localDBWhereExp = new DBWhereExp();
	    EnpObjClass localEnpObjClass = EnpObjClass.getInstance(paramxBaseObj.getClass());
	    try
	    {
	      int i = paramString.indexOf(46);
	      if (i > 0)
	      {
	    	Field localField = localEnpObjClass.getField(paramString.substring(i + 1));
	        localDBWhereExp.jm1(paramString, localField.get(paramxBaseObj), "<>");
	      /*  break label108:*/
	      }
	      Field localField = localEnpObjClass.getField(paramString);
	      localDBWhereExp.jm1(paramString, localField.get(paramxBaseObj), "<>");
	    }
	    catch (Exception localException)
	    {
	      logobj.error(localException);
	      return null;
	    }
	    label108: return localDBWhereExp;
	  }

	  public static DBWhereExp exists(String paramString)
	  {
	    if (paramString == null)
	      return null;
	    DBWhereExp localDBWhereExp = new DBWhereExp();
	    localDBWhereExp.jm1(paramString, null, "exists");
	    return localDBWhereExp;
	  }

	  public static DBWhereExp exists(DBQuery paramDBQuery)
	  {
	    if (paramDBQuery == null)
	      return null;
	    DBWhereExp localDBWhereExp = new DBWhereExp();
	    localDBWhereExp.jm1(null, paramDBQuery, "exists");
	    return localDBWhereExp;
	  }

	  public static DBWhereExp notExists(String paramString)
	  {
	    if (paramString == null)
	      return null;
	    DBWhereExp localDBWhereExp = new DBWhereExp();
	    localDBWhereExp.jm1(paramString, null, "notexists");
	    return localDBWhereExp;
	  }

	  public static DBWhereExp notExists(DBQuery paramDBQuery)
	  {
	    if (paramDBQuery == null)
	      return null;
	    DBWhereExp localDBWhereExp = new DBWhereExp();
	    localDBWhereExp.jm1(null, paramDBQuery, "notexists");
	    return localDBWhereExp;
	  }

	  public static DBWhereExp eq(String paramString, int paramInt)
	  {
	    if (paramString == null)
	      return null;
	    DBWhereExp localDBWhereExp = new DBWhereExp();
	    localDBWhereExp.jm1(paramString, new Integer(paramInt), "=");
	    return localDBWhereExp;
	  }

	  public static DBWhereExp eq(String paramString1, String paramString2)
	  {
	    if (paramString1 == null)
	      return null;
	    DBWhereExp localDBWhereExp = new DBWhereExp();
	    if (paramString2 == null)
	      paramString2 = "";
	    localDBWhereExp.jm1(paramString1, paramString2, "=");
	    return localDBWhereExp;
	  }

	  public static DBWhereExp ne(String paramString, int paramInt)
	  {
	    if (paramString == null)
	      return null;
	    DBWhereExp localDBWhereExp = new DBWhereExp();
	    localDBWhereExp.jm1(paramString, new Integer(paramInt), "<>");
	    return localDBWhereExp;
	  }

	  public static DBWhereExp ne(String paramString1, String paramString2)
	  {
	    if (paramString1 == null)
	      return null;
	    DBWhereExp localDBWhereExp = new DBWhereExp();
	    localDBWhereExp.jm1(paramString1, paramString2, "<>");
	    return localDBWhereExp;
	  }

	  public static DBWhereExp in(String paramString1, String paramString2)
	  {
	    if (paramString1 == null)
	      return null;
	    DBWhereExp localDBWhereExp = new DBWhereExp();
	    if ((paramString2 == null) || (paramString2.length() < 1))
	      localDBWhereExp.jm1("1=0", null, null);
	    else
	      localDBWhereExp.jm1(paramString1, paramString2, "in");
	    return localDBWhereExp;
	  }

	  public static DBWhereExp in(String paramString, DBQuery paramDBQuery)
	  {
	    if (paramString == null)
	      return null;
	    DBWhereExp localDBWhereExp = new DBWhereExp();
	    localDBWhereExp.jm1(paramString, paramDBQuery, "in");
	    return localDBWhereExp;
	  }

	  public static DBWhereExp in(String paramString, Collection paramCollection, boolean paramBoolean)
	  {
	    if (paramString == null)
	      return null;
	    if ((paramCollection == null) || (paramCollection.size() < 1))
	      return new DBWhereExp("1=0");
	    Vector localVector = new Vector(paramCollection.size());
	    localVector.addAll(paramCollection);
	    DBWhereExp localDBWhereExp = new DBWhereExp();
	    if (paramBoolean)
	      localDBWhereExp.jm1(paramString, localVector, "invstr");
	    else
	      localDBWhereExp.jm1(paramString, localVector, "inv");
	    return localDBWhereExp;
	  }

	  public static DBWhereExp in(String paramString, Collection paramCollection, Class paramClass)
	  {
	    if (paramString == null)
	      return null;
	    if ((paramCollection == null) || (paramCollection.size() < 1))
	      return new DBWhereExp("1=0");
	    Vector localVector = new Vector(paramCollection.size());
	    localVector.addAll(paramCollection);
	    DBWhereExp localDBWhereExp = new DBWhereExp();
	    if ("java.lang.String".equals(paramClass.getName()))
	      localDBWhereExp.jm1(paramString, localVector, "invstr");
	    else
	      localDBWhereExp.jm1(paramString, localVector, "inv");
	    return localDBWhereExp;
	  }

	  public static DBWhereExp notIn(String paramString1, String paramString2)
	  {
	    if (paramString1 == null)
	      return null;
	    DBWhereExp localDBWhereExp = new DBWhereExp();
	    localDBWhereExp.jm1(paramString1, paramString2, "notin");
	    return localDBWhereExp;
	  }

	  public static DBWhereExp notIn(String paramString, DBQuery paramDBQuery)
	  {
	    if (paramString == null)
	      return null;
	    DBWhereExp localDBWhereExp = new DBWhereExp();
	    localDBWhereExp.jm1(paramString, paramDBQuery, "notin");
	    return localDBWhereExp;
	  }

	  public static DBWhereExp notIn(String paramString, Collection paramCollection, boolean paramBoolean)
	  {
	    if (paramString == null)
	      return null;
	    if ((paramCollection == null) || (paramCollection.size() < 1))
	      return null;
	    Vector localVector = new Vector(paramCollection.size());
	    localVector.addAll(paramCollection);
	    DBWhereExp localDBWhereExp = new DBWhereExp();
	    if (paramBoolean)
	      localDBWhereExp.jm1(paramString, localVector, "notinvstr");
	    else
	      localDBWhereExp.jm1(paramString, localVector, "notinv");
	    return localDBWhereExp;
	  }

	  public static DBWhereExp notIn(String paramString, Collection paramCollection, Class paramClass)
	  {
	    if (paramString == null)
	      return null;
	    if ((paramCollection == null) || (paramCollection.size() < 1))
	      return null;
	    Vector localVector = new Vector(paramCollection.size());
	    localVector.addAll(paramCollection);
	    DBWhereExp localDBWhereExp = new DBWhereExp();
	    if ("java.lang.String".equals(paramClass.getName()))
	      localDBWhereExp.jm1(paramString, localVector, "notinvstr");
	    else
	      localDBWhereExp.jm1(paramString, localVector, "notinv");
	    return localDBWhereExp;
	  }

	  public static DBWhereExp gt(String paramString, int paramInt)
	  {
	    if (paramString == null)
	      return null;
	    DBWhereExp localDBWhereExp = new DBWhereExp();
	    localDBWhereExp.jm1(paramString, new Integer(paramInt), ">");
	    return localDBWhereExp;
	  }

	  public static DBWhereExp gt(String paramString1, String paramString2)
	  {
	    if (paramString1 == null)
	      return null;
	    DBWhereExp localDBWhereExp = new DBWhereExp();
	    localDBWhereExp.jm1(paramString1, paramString2, ">");
	    return localDBWhereExp;
	  }

	  public static DBWhereExp lt(String paramString, int paramInt)
	  {
	    if (paramString == null)
	      return null;
	    DBWhereExp localDBWhereExp = new DBWhereExp();
	    localDBWhereExp.jm1(paramString, new Integer(paramInt), "<");
	    return localDBWhereExp;
	  }

	  public static DBWhereExp lt(String paramString1, String paramString2)
	  {
	    if (paramString1 == null)
	      return null;
	    DBWhereExp localDBWhereExp = new DBWhereExp();
	    localDBWhereExp.jm1(paramString1, paramString2, "<");
	    return localDBWhereExp;
	  }

	  public static DBWhereExp ge(String paramString, int paramInt)
	  {
	    if (paramString == null)
	      return null;
	    DBWhereExp localDBWhereExp = new DBWhereExp();
	    localDBWhereExp.jm1(paramString, new Integer(paramInt), ">=");
	    return localDBWhereExp;
	  }

	  public static DBWhereExp ge(String paramString1, String paramString2)
	  {
	    if (paramString1 == null)
	      return null;
	    DBWhereExp localDBWhereExp = new DBWhereExp();
	    localDBWhereExp.jm1(paramString1, paramString2, ">=");
	    return localDBWhereExp;
	  }

	  public static DBWhereExp le(String paramString, int paramInt)
	  {
	    if (paramString == null)
	      return null;
	    DBWhereExp localDBWhereExp = new DBWhereExp();
	    localDBWhereExp.jm1(paramString, new Integer(paramInt), "<=");
	    return localDBWhereExp;
	  }

	  public static DBWhereExp le(String paramString1, String paramString2)
	  {
	    if (paramString1 == null)
	      return null;
	    DBWhereExp localDBWhereExp = new DBWhereExp();
	    localDBWhereExp.jm1(paramString1, paramString2, "<=");
	    return localDBWhereExp;
	  }

	  public static DBWhereExp like(String paramString1, String paramString2)
	  {
	    if (paramString1 == null)
	      return null;
	    DBWhereExp localDBWhereExp = new DBWhereExp();
	    localDBWhereExp.jm1(paramString1, paramString2, "like");
	    return localDBWhereExp;
	  }

	  public static DBWhereExp likeAll(String paramString1, String paramString2)
	  {
	    if (paramString1 == null)
	      return null;
	    DBWhereExp localDBWhereExp = new DBWhereExp();
	    localDBWhereExp.jm1(paramString1, paramString2, "likeall");
	    return localDBWhereExp;
	  }

	  public static DBWhereExp notLike(String paramString1, String paramString2)
	  {
	    if (paramString1 == null)
	      return null;
	    DBWhereExp localDBWhereExp = new DBWhereExp();
	    localDBWhereExp.jm1(paramString1, paramString2, "notlike");
	    return localDBWhereExp;
	  }

	  public static DBWhereExp notLikeAll(String paramString1, String paramString2)
	  {
	    if (paramString1 == null)
	      return null;
	    DBWhereExp localDBWhereExp = new DBWhereExp();
	    localDBWhereExp.jm1(paramString1, paramString2, "notlikeall");
	    return localDBWhereExp;
	  }

	  public static DBWhereExp strNotNull(String paramString)
	  {
	    if (paramString == null)
	      return null;
	    DBWhereExp localDBWhereExp = new DBWhereExp();
	    localDBWhereExp.jm1(paramString, null, "strnotnull");
	    return localDBWhereExp;
	  }

	  public static DBWhereExp strIsNull(String paramString)
	  {
	    if (paramString == null)
	      return null;
	    DBWhereExp localDBWhereExp = new DBWhereExp();
	    localDBWhereExp.jm1(paramString, null, "strisnull");
	    return localDBWhereExp;
	  }

	  public static DBWhereExp commSearch(xBaseObj paramxBaseObj, List paramList)
	  {
	    if (paramxBaseObj == null)
	      return null;
	    DBWhereExp localDBWhereExp = new DBWhereExp();
	    EnpObjClass localEnpObjClass = EnpObjClass.getInstance(paramxBaseObj.getClass());
	    try
	    {
	      int j = paramList.size();
	      Field localField = null;
	      for (int k = 0; k < j; ++k)
	      {
	        String str = (String)paramList.get(k);
	        int i = str.indexOf(46);
	        if (i > 0)
	          localField = localEnpObjClass.getField(str.substring(i + 1));
	        else
	          localField = localEnpObjClass.getField(str);
	        if (localField == null)
	          continue;
	        Object localObject = localField.get(paramxBaseObj);
	        if (localObject == null)
	          continue;
	        if (localObject.toString().length() < 1)
	          continue;
	        if ("sqlwhere".equalsIgnoreCase(str))
	        {
	          localDBWhereExp.and(new DBWhereExp(localObject.toString()));
	        }
	        else if (localEnpObjClass.isNumber(localField))
	        {
	          if ("0".equals(localObject.toString()))
	            continue;
	          localDBWhereExp.jm1(str, localObject, "=");
	        }
	        else
	        {
	          localDBWhereExp.jm1(str, localObject, "like");
	        }
	      }
	    }
	    catch (Exception localException)
	    {
	      logobj.error(localException);
	      return null;
	    }
	    return localDBWhereExp;
	  }

	  public static DBWhereExp custom(String paramString, Object[] paramArrayOfObject)
	  {
	    DBWhereExp localDBWhereExp = new DBWhereExp();
	    localDBWhereExp.jm1(paramString, paramArrayOfObject);
	    return localDBWhereExp;
	  }

	  public static void main(String[] paramArrayOfString)
	  {
	    DBWhereExp localDBWhereExp1 = new DBWhereExp(" wHere tss.tssid=pc.tssid");
	    DBWhereExp localDBWhereExp2 = eq("pc.revtype", 1);
	    localDBWhereExp2.or(gt("pc.revtype", 3));
	    localDBWhereExp1.andSubExp(localDBWhereExp2);
	    localDBWhereExp1.and(like("tss.code", "p"));
	    localDBWhereExp1.and(in("pc.superid", "1,2,3"));
	    System.out.println(localDBWhereExp1.toSQL(2));
	    Object[] arrayOfObject = new Object[3];
	    arrayOfObject[0] = new Integer(1);
	    arrayOfObject[1] = "admin";
	    arrayOfObject[2] = new XDate();
	    localDBWhereExp1 = custom("where entid=? and userid=? and count=?", arrayOfObject);
	    System.out.println(localDBWhereExp1.toSQL(1));
	    localDBWhereExp1 = eq("a", 1).and(ne("b", 0));
	    System.out.println(localDBWhereExp1.toSQL(2));
	  }

	  static String jm4(DBWhereExp paramDBWhereExp, Class paramClass)
	  {
	    return paramDBWhereExp.jm0(paramClass);
	  }

	  static Log jm5()
	  {
	    return logobj;
	  }

	  public class ExpItem
	  {
	    String jm553;
	    Object jm554;
	    Object[] jm555;
	    String jm556;
	    boolean jm8;

	    public ExpItem(String paramString1, Object paramObject, String paramString2)
	    {
	      this.jm553 = paramString1;
	      this.jm554 = paramObject;
	      this.jm556 = paramString2;
	      this.jm8 = true;
	    }

	    public ExpItem(String paramString, Object[] paramArrayOfObject)
	    {
	      this.jm553 = paramString;
	      this.jm555 = paramArrayOfObject;
	      this.jm8 = true;
	    }

	    public void setAnd(boolean paramBoolean)
	    {
	      this.jm8 = paramBoolean;
	    }

	    public String toSQL(int paramInt)
	    {
	      Object localObject;
	      int i;
	      if ((this.jm556 == null) || (this.jm556.length() < 1))
	      {
	        if (this.jm555 != null)
	        {
	          localObject = new StringBuffer(32);
	          i = 0;
	          int j = 0;
	          int k = 0;
	         
	          while (true)
	          {
	            j = this.jm553.indexOf(63, i);
	            if (j >= 0)
	            {
	              ((StringBuffer)localObject).append(this.jm553.substring(i, j));
	              i = j + 1;
	              ((StringBuffer)localObject).append(jm552(this.jm555[k], paramInt, 0));
	              ++k;
	              label107: if (k < this.jm555.length)
	               
	               return ((StringBuffer)localObject).toString();
	            }
	          }
	        }
	        return this.jm553;
	      }
	      if (this.jm556.equals("exists"))
	      {
	        if (this.jm554 != null)
	          return " EXISTS(" + ((DBQuery)this.jm554).toSQL(paramInt) + ")";
	        return " EXISTS(" + this.jm553 + ")";
	      }
	      if (this.jm556.equals("notexists"))
	      {
	        if (this.jm554 != null)
	          return " NOT EXISTS(" + ((DBQuery)this.jm554).toSQL(paramInt) + ")";
	        return " NOT EXISTS(" + this.jm553 + ")";
	      }
	      if (this.jm556.equals("in"))
	      {
	        localObject = new StringBuffer(128);
	        ((StringBuffer)localObject).append(this.jm553);
	        ((StringBuffer)localObject).append(" IN(");
	        if (this.jm554 instanceof DBQuery)
	          ((StringBuffer)localObject).append(((DBQuery)this.jm554).toSQL(paramInt));
	        else
	          ((StringBuffer)localObject).append(this.jm554.toString());
	        ((StringBuffer)localObject).append(")");
	        return ((StringBuffer)localObject).toString();
	      }
	      boolean bool;
	      StringBuffer localStringBuffer;
	      int l;
	      int i1;
	      if ((this.jm556.equals("inv")) || (this.jm556.equals("invstr")))
	      {
	        localObject = (Vector)this.jm554;
	        i = ((Vector)localObject).size();
	        bool = this.jm556.equals("invstr");
	        localStringBuffer = new StringBuffer(i * 10);
	        if ((1 == paramInt) && (i > 1000))
	          localStringBuffer.append('(');
	        localStringBuffer.append(this.jm553);
	        localStringBuffer.append(" IN(");
	        l = 0;
	        for (i1 = 0; i1 < i; ++i1)
	          if (1 == paramInt)
	          {
	            if (l > 999)
	            {
	              localStringBuffer.append(") OR ");
	              localStringBuffer.append(this.jm553);
	              localStringBuffer.append(" IN(");
	              l = 1;
	            }
	            else
	            {
	              ++l;
	            }
	            if (l > 1)
	              localStringBuffer.append(',');
	            if (bool)
	              localStringBuffer.append('\'');
	            localStringBuffer.append(((Vector)localObject).get(i1));
	            if (!(bool))
	              continue;
	            localStringBuffer.append('\'');
	          }
	          else
	          {
	            if (i1 > 0)
	              localStringBuffer.append(',');
	            if (bool)
	              localStringBuffer.append('\'');
	            localStringBuffer.append(((Vector)localObject).get(i1));
	            if (!(bool))
	              continue;
	            localStringBuffer.append('\'');
	          }
	        localStringBuffer.append(')');
	        localObject = null;
	        if ((1 == paramInt) && (i > 1000))
	          localStringBuffer.append(')');
	        return localStringBuffer.toString();
	      }
	      if (this.jm556.equals("notin"))
	      {
	        localObject = new StringBuffer(128);
	        ((StringBuffer)localObject).append(this.jm553);
	        ((StringBuffer)localObject).append(" NOT IN(");
	        if (this.jm554 instanceof DBQuery)
	          ((StringBuffer)localObject).append(((DBQuery)this.jm554).toSQL(paramInt));
	        else
	          ((StringBuffer)localObject).append(this.jm554.toString());
	        ((StringBuffer)localObject).append(")");
	        return ((StringBuffer)localObject).toString();
	      }
	      if ((this.jm556.equals("notinv")) || (this.jm556.equals("notinvstr")))
	      {
	        localObject = (Vector)this.jm554;
	        i = ((Vector)localObject).size();
	        bool = this.jm556.equals("notinvstr");
	        localStringBuffer = new StringBuffer(i * 10);
	        if ((1 == paramInt) && (i > 1000))
	          localStringBuffer.append('(');
	        localStringBuffer.append(this.jm553);
	        localStringBuffer.append(" NOT IN(");
	        l = 0;
	        for (i1 = 0; i1 < i; ++i1)
	          if (1 == paramInt)
	          {
	            if (l > 999)
	            {
	              localStringBuffer.append(") AND ");
	              localStringBuffer.append(this.jm553);
	              localStringBuffer.append(" NOT IN(");
	              l = 1;
	            }
	            else
	            {
	              ++l;
	            }
	            if (l > 1)
	              localStringBuffer.append(',');
	            if (bool)
	              localStringBuffer.append('\'');
	            localStringBuffer.append(((Vector)localObject).get(i1));
	            if (!(bool))
	              continue;
	            localStringBuffer.append('\'');
	          }
	          else
	          {
	            if (i1 > 0)
	              localStringBuffer.append(',');
	            if (bool)
	              localStringBuffer.append('\'');
	            localStringBuffer.append(((Vector)localObject).get(i1));
	            if (!(bool))
	              continue;
	            localStringBuffer.append('\'');
	          }
	        localStringBuffer.append(')');
	        localObject = null;
	        if ((1 == paramInt) && (i > 1000))
	          localStringBuffer.append(')');
	        return localStringBuffer.toString();
	      }
	      if (this.jm556.equals("like"))
	        return this.jm553 + " LIKE " + jm552(this.jm554, paramInt, 1);
	      if (this.jm556.equals("likeall"))
	        return this.jm553 + " LIKE " + jm552(this.jm554, paramInt, 2);
	      if (this.jm556.equals("notlike"))
	        return this.jm553 + " NOT LIKE " + jm552(this.jm554, paramInt, 1);
	      if (this.jm556.equals("notlikeall"))
	        return this.jm553 + " NOT LIKE " + jm552(this.jm554, paramInt, 2);
	      if (this.jm556.equals("strnotnull"))
	      {
	        if (1 == paramInt)
	          return this.jm553 + " is not null";
	        localObject = new StringBuffer(32);
	        ((StringBuffer)localObject).append('(');
	        ((StringBuffer)localObject).append(this.jm553);
	        ((StringBuffer)localObject).append(" is not null AND ");
	        ((StringBuffer)localObject).append(this.jm553);
	        ((StringBuffer)localObject).append("<>'')");
	        return ((StringBuffer)localObject).toString();
	      }
	      if (this.jm556.equals("strisnull"))
	      {
	        if (1 == paramInt)
	          return this.jm553 + " is null";
	        localObject = new StringBuffer(32);
	        ((StringBuffer)localObject).append('(');
	        ((StringBuffer)localObject).append(this.jm553);
	        ((StringBuffer)localObject).append(" is null OR ");
	        ((StringBuffer)localObject).append(this.jm553);
	        ((StringBuffer)localObject).append("='')");
	        return ((StringBuffer)localObject).toString();
	      }
	      return ((String)this.jm553 + this.jm556 + jm552(this.jm554, paramInt, 0));
	    }

	    public String toDBSQL(int paramInt, DBSQL paramDBSQL)
	    {
	      if ((this.jm556 == null) || (this.jm556.length() < 1))
	      {
	        if (this.jm555 != null)
	        {
	          int i = 0;
	        
	          while (true)
	          {
	            paramDBSQL.addParam(this.jm555[i]);
	            ++i;
	            if (i >= this.jm555.length)
	              label43: return this.jm553;
	          }
	        }
	        return this.jm553;
	      }
	      if (this.jm556.equals("exists"))
	      {
	        if (this.jm554 != null)
	          return " EXISTS(" + ((DBQuery)this.jm554).toSQL(paramInt) + ")";
	        return " EXISTS(" + this.jm553 + ")";
	      }
	      if (this.jm556.equals("notexists"))
	      {
	        if (this.jm554 != null)
	          return " NOT EXISTS(" + ((DBQuery)this.jm554).toSQL(paramInt) + ")";
	        return " NOT EXISTS(" + this.jm553 + ")";
	      }
	      Object localObject;
	      if (this.jm556.equals("in"))
	      {
	        localObject = new StringBuffer(128);
	        ((StringBuffer)localObject).append(this.jm553);
	        ((StringBuffer)localObject).append(" IN(");
	        if (this.jm554 instanceof DBQuery)
	          ((StringBuffer)localObject).append(((DBQuery)this.jm554).toSQL(paramInt));
	        else
	          ((StringBuffer)localObject).append(this.jm554.toString());
	        ((StringBuffer)localObject).append(")");
	        return ((StringBuffer)localObject).toString();
	      }
	      int j;
	      boolean bool;
	      StringBuffer localStringBuffer;
	      int k;
	      int l;
	      if ((this.jm556.equals("inv")) || (this.jm556.equals("invstr")))
	      {
	        localObject = (Vector)this.jm554;
	        j = ((Vector)localObject).size();
	        bool = this.jm556.equals("invstr");
	        localStringBuffer = new StringBuffer(j * 10);
	        if ((1 == paramInt) && (j > 1000))
	          localStringBuffer.append('(');
	        localStringBuffer.append(this.jm553);
	        localStringBuffer.append(" IN(");
	        if (j <= 128)
	        {
	          for (k = 0; k < j; ++k)
	          {
	            if (k > 0)
	              localStringBuffer.append(',');
	            localStringBuffer.append('?');
	            if (bool)
	              paramDBSQL.addString(((Vector)localObject).get(k).toString());
	            else
	              paramDBSQL.addInt(Integer.parseInt(((Vector)localObject).get(k).toString()));
	          }
	        }
	        else
	        {
	          k = 0;
	          for (l = 0; l < j; ++l)
	            if (1 == paramInt)
	            {
	              if (k > 999)
	              {
	                localStringBuffer.append(") OR ");
	                localStringBuffer.append(this.jm553);
	                localStringBuffer.append(" IN(");
	                k = 1;
	              }
	              else
	              {
	                ++k;
	              }
	              if (k > 1)
	                localStringBuffer.append(',');
	              if (bool)
	                localStringBuffer.append('\'');
	              localStringBuffer.append(((Vector)localObject).get(l));
	              if (!(bool))
	                continue;
	              localStringBuffer.append('\'');
	            }
	            else
	            {
	              if (l > 0)
	                localStringBuffer.append(',');
	              if (bool)
	                localStringBuffer.append('\'');
	              localStringBuffer.append(((Vector)localObject).get(l));
	              if (!(bool))
	                continue;
	              localStringBuffer.append('\'');
	            }
	        }
	        localStringBuffer.append(')');
	        localObject = null;
	        if ((1 == paramInt) && (j > 1000))
	          localStringBuffer.append(')');
	        return localStringBuffer.toString();
	      }
	      if (this.jm556.equals("notin"))
	      {
	        localObject = new StringBuffer(128);
	        ((StringBuffer)localObject).append(this.jm553);
	        ((StringBuffer)localObject).append(" NOT IN(");
	        if (this.jm554 instanceof DBQuery)
	          ((StringBuffer)localObject).append(((DBQuery)this.jm554).toSQL(paramInt));
	        else
	          ((StringBuffer)localObject).append(this.jm554.toString());
	        ((StringBuffer)localObject).append(")");
	        return ((StringBuffer)localObject).toString();
	      }
	      if ((this.jm556.equals("notinv")) || (this.jm556.equals("notinvstr")))
	      {
	        localObject = (Vector)this.jm554;
	        j = ((Vector)localObject).size();
	        bool = this.jm556.equals("notinvstr");
	        localStringBuffer = new StringBuffer(j * 10);
	        if ((1 == paramInt) && (j > 1000))
	          localStringBuffer.append('(');
	        localStringBuffer.append(this.jm553);
	        localStringBuffer.append(" NOT IN(");
	        if (j <= 128)
	        {
	          for (k = 0; k < j; ++k)
	          {
	            if (k > 0)
	              localStringBuffer.append(',');
	            localStringBuffer.append('?');
	            if (bool)
	              paramDBSQL.addString(((Vector)localObject).get(k).toString());
	            else
	              paramDBSQL.addInt(Integer.parseInt(((Vector)localObject).get(k).toString()));
	          }
	        }
	        else
	        {
	          k = 0;
	          for (l = 0; l < j; ++l)
	            if (1 == paramInt)
	            {
	              if (k > 999)
	              {
	                localStringBuffer.append(") AND ");
	                localStringBuffer.append(this.jm553);
	                localStringBuffer.append(" NOT IN(");
	                k = 1;
	              }
	              else
	              {
	                ++k;
	              }
	              if (k > 1)
	                localStringBuffer.append(',');
	              if (bool)
	                localStringBuffer.append('\'');
	              localStringBuffer.append(((Vector)localObject).get(l));
	              if (!(bool))
	                continue;
	              localStringBuffer.append('\'');
	            }
	            else
	            {
	              if (l > 0)
	                localStringBuffer.append(',');
	              if (bool)
	                localStringBuffer.append('\'');
	              localStringBuffer.append(((Vector)localObject).get(l));
	              if (!(bool))
	                continue;
	              localStringBuffer.append('\'');
	            }
	        }
	        localStringBuffer.append(')');
	        localObject = null;
	        if ((1 == paramInt) && (j > 1000))
	          localStringBuffer.append(')');
	        return localStringBuffer.toString();
	      }
	      if (this.jm556.equals("like"))
	      {
	        paramDBSQL.addString(this.jm554 + "%");
	        return this.jm553 + " LIKE ?";
	      }
	      if (this.jm556.equals("likeall"))
	      {
	        paramDBSQL.addString("%" + this.jm554 + "%");
	        return this.jm553 + " LIKE ?";
	      }
	      if (this.jm556.equals("notlike"))
	      {
	        paramDBSQL.addString(this.jm554 + "%");
	        return this.jm553 + " NOT LIKE ?";
	      }
	      if (this.jm556.equals("notlikeall"))
	      {
	        paramDBSQL.addString("%" + this.jm554 + "%");
	        return this.jm553 + " NOT LIKE ?";
	      }
	      if (this.jm556.equals("strnotnull"))
	      {
	        if (1 == paramInt)
	          return this.jm553 + " is not null";
	        localObject = new StringBuffer(32);
	        ((StringBuffer)localObject).append('(');
	        ((StringBuffer)localObject).append(this.jm553);
	        ((StringBuffer)localObject).append(" is not null AND ");
	        ((StringBuffer)localObject).append(this.jm553);
	        ((StringBuffer)localObject).append("<>'')");
	        return ((StringBuffer)localObject).toString();
	      }
	      if (this.jm556.equals("strisnull"))
	      {
	        if (1 == paramInt)
	          return this.jm553 + " is null";
	        localObject = new StringBuffer(32);
	        ((StringBuffer)localObject).append('(');
	        ((StringBuffer)localObject).append(this.jm553);
	        ((StringBuffer)localObject).append(" is null OR ");
	        ((StringBuffer)localObject).append(this.jm553);
	        ((StringBuffer)localObject).append("='')");
	        return ((StringBuffer)localObject).toString();
	      }
	      paramDBSQL.addParam(this.jm554);
	      return ((String)this.jm553 + this.jm556 + "?");
	    }

	    private String jm552(Object paramObject, int paramInt1, int paramInt2)
	    {
	      try
	      {
	        String str = DBWhereExp.jm4(DBWhereExp.this, paramObject.getClass());
	        StringBuffer localStringBuffer = new StringBuffer(64);
	        if (str.equals("string"))
	        {
	          localStringBuffer.append('\'');
	          if (paramInt2 == 2)
	            localStringBuffer.append('%');
	          localStringBuffer.append(DataFilter.filterStringToDB(paramObject));
	          if (paramInt2 > 0)
	            localStringBuffer.append('%');
	          localStringBuffer.append('\'');
	        }
	        else if (str.equals("date"))
	        {
	          java.util.Date localDate = (java.util.Date)paramObject;
	          SimpleDateFormat localSimpleDateFormat;
	          if (paramInt1 == 1)
	          {
	            localSimpleDateFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
	            localStringBuffer.append("to_date('");
	            localStringBuffer.append(localSimpleDateFormat.format(localDate));
	            localStringBuffer.append("','MM/DD/YYYY HH24:MI:SS')");
	          }
	          else
	          {
	            localSimpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
	            localStringBuffer.append('\'');
	            localStringBuffer.append(localSimpleDateFormat.format(localDate));
	            localStringBuffer.append('\'');
	          }
	        }
	        else
	        {
	          localStringBuffer.append(paramObject.toString());
	        }
	        return localStringBuffer.toString();
	      }
	      catch (Exception localException)
	      {
	        DBWhereExp.jm5().error(localException);
	      }
	      return null;
	    }
	  }
}
